<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>变量与常量声明</title>
</head>
<body>
    <script>
        //JS是一门弱类型语言，不需要明确变量的数据类型
        //1.声明变量
        var a = 1;
        var b = 3.14;
        var c = '你好';
        var d = "你好呀！";//字符串:单引双引均可,JS没有单个字符char类型
        var e = true;
        //可以同时查看多个变量的值，逗号隔开
        console.log(a,b,c,d,e);
        //2.可以通过typeof查看变量的类型
        console.log(typeof a,typeof b,typeof c,typeof d,typeof e);
        //3.JS的变量类型可以根据值的变化而修改
        a=false;
        console.log(a,typeof a);//从number改成了boolean
        //4.var声明的变量允许重复声明
        var a = '哈哈哈哈我又来了';
        console.log(a,typeof a);//从number改成了boolean
        //5.let的变量可以换数据类型，但是不允许重复声明
        let x = 1;
        x = '哈哈哈';
        console.log(x);
        //let x = true;//SyntaxError: Identifier 'x' has already been declared
        //6.声明常量:
        const y = 1;
        console.log(y)
        //y = 5.6;//TypeError: Assignment to constant variable.
    </script> //15:17继续
</body>
</html>